import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import AutoImport from "unplugin-auto-import/vite";
import Components from "unplugin-vue-components/vite";
import { ElementPlusResolver } from "unplugin-vue-components/resolvers";
import { resolve } from "path";

// https://vitejs.dev/config/
export default defineConfig({
    base: "/fat-form",
    plugins: [
        vue(),
        AutoImport({
            resolvers: [ElementPlusResolver()],
            imports: ["vue"],
            dts: "src/types/auto-imports.d.ts",
        }),
        Components({
            resolvers: [ElementPlusResolver()],
            dts: "src/types/components.d.ts",
        }),
    ],
    resolve: {
        alias: {
            "@": resolve(__dirname, "./src"),
        },
    },
    server: {
        proxy: {
            "/upload": {
                target: "http://www.qx-os.com:8885/file/upload.uf",
                changeOrigin: true,
                rewrite: (path) => path.replace(/^\/upload/, ""),
            },
        },
    },
});